﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace ThePushCSharp
{
    abstract public class Entity
    {
        public String name;
        public String description;
        public Player owner;
        public Texture2D unitTexture;
        public int health;
        public int armor;
        public String armorType;
        public int visibility;

        public Entity()
        {
        }

        public Entity(Player owner)
        {
        }

        public Color getColor()
        {
            return owner.color;
        }
    }

    public class Wall : Entity
    {
        public Wall(Player owner, GameState game)
        {
            name = "Wall";
            description = "Walls are difficult to break down, and they protect important areas such as the Headquarters.";
            health = 55;
            armor = 10;
            visibility = 3;
            armorType = "Structure";
            this.owner = owner;
            this.unitTexture = game.push.Content.Load<Texture2D>("wall");
        }
    }

    public class Headquarters : Entity
    {
        public Headquarters(Player owner, GameState game)
        {
            name = "Headquarters";
            description = "Headquarters are the final defense for a country.  When a Headquarters is lost, the war is lost!  So guard this well!";
            health = 555;
            armor = 55;
            visibility = 6;
            armorType = "Structure";
            this.owner = owner;
            this.unitTexture = game.push.Content.Load<Texture2D>("headquarters");
        }
    }

    public class Outpost : Entity
    {
        public Outpost(Player owner, GameState game)
        {
            name = "Outpost";
            description = "Headquarters are the final defense for a country.  When a Headquarters is lost, the war is lost!  So guard this well!";
            health = 555;
            armor = 55;
            armorType = "Structure";
            visibility = 6;
            this.owner = owner;
            this.unitTexture = game.push.Content.Load<Texture2D>("outpost");
        }
    }

    abstract public class Troop : Entity
    {
        public String weapon;
        public int movesPerTurn;
        public AttackType attackTypeInfantry;
        public AttackType attackTypeMechanical;
        public int attacksPerTurn;
        public int cost;
        public bool infantry;

        public int movesLeft;
        public int attacksLeft;

        public void newTurn()
        {
            movesLeft = movesPerTurn;
            attacksLeft = attacksPerTurn;
        }

        public Troop()
        {

        }

        public Troop(Player owner)
        {
        }
    }

    public class FootSoldier : Troop
    {
        public FootSoldier(Player owner, GameState game)
        {
            name = "Foot Soldier";
            description = "A Foot Soldier is great for all around combat.";
            health = 5;
            armor = 0;
            armorType = "Medium";
            visibility = 3;
            infantry = true;
            this.owner = owner;

            cost = 1;
            weapon = "Assault Rifle with mounted Grenade Launcher";
            movesPerTurn = 4;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.PIERCING, 3, 0, 3);
            attackTypeMechanical = new AttackType(AttackType.EXPLOSIVE, 3, 0, 3);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("footSoldier");
        }
    }

    public class Medic : Troop
    {
        public Medic(Player owner, GameState game)
        {
            name = "Medic";
            description = "A Medic unit is terrible in combat but great at supporting infantry.";
            health = 5;
            armor = 0;
            armorType = "Medium";
            visibility = 2;
            infantry = true;
            this.owner = owner;

            cost = 1;
            weapon = "Med Pack and Pistol";
            movesPerTurn = 5;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.BLUNT, 1, 0, 1);
            attackTypeMechanical = new AttackType(AttackType.BLUNT, 1, 0, 1);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("medic");
        }
    }

    public class Scout : Troop
    {
        public Scout(Player owner, GameState game)
        {
            name = "Scout";
            description = "A Scout is quick and great for exploring, but a terrible fighter.";
            health = 3;
            armor = 0;
            armorType = "Light";
            visibility = 8;
            infantry = true;
            this.owner = owner;

            cost = 2;
            weapon = "Semi-Automatic Rifle";
            movesPerTurn = 6;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.BLUNT, 2, 0, 2);
            attackTypeMechanical = new AttackType(AttackType.BLUNT, 2, 0, 2);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("scout");
        }
    }

    public class Sniper : Troop
    {
        public Sniper(Player owner, GameState game)
        {
            name = "Sniper";
            description = "A Sniper is a long range infantry unit.";
            health = 4;
            armor = 0;
            armorType = "Light";
            visibility = 6;
            infantry = true;
            this.owner = owner;

            cost = 3;
            weapon = "Sniper Rifle";
            movesPerTurn = 4;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.PIERCING, 5, 1, 4);
            attackTypeMechanical = new AttackType(AttackType.PIERCING, 5, 1, 4);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("sniper");
        }
    }

    public class HeavyWeapons : Troop
    {
        public HeavyWeapons(Player owner, GameState game)
        {
            name = "Heavy Weapons";
            description = "A Heavy Weapons unit is strong, slow and versatile.  Great at assaulting vehicles.";
            health = 7;
            armor = 1;
            armorType = "Light";
            visibility = 3;
            infantry = true;
            this.owner = owner;

            cost = 3;
            weapon = "Shot-Gun and Rocket Launcher";
            movesPerTurn = 4;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.BLUNT, 1, 0, 2);
            attackTypeMechanical = new AttackType(AttackType.EXPLOSIVE, 3, 0, 7);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("heavyWeapons");
        }
    }

    public class Jeep : Troop
    {
        public Jeep(Player owner, GameState game)
        {
            name = "Jeep";
            description = "A Jeep is fast and efficient for scouting while retaining good combat ability.";
            health = 10;
            armor = 2;
            armorType = "Medium";
            visibility = 3;
            infantry = false;
            this.owner = owner;

            cost = 6;
            weapon = "Machine Gun";
            movesPerTurn = 6;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.PIERCING, 3, 0, 4);
            attackTypeMechanical = new AttackType(AttackType.BLUNT, 3, 0, 4);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("jeep");
        }
    }

    public class APC : Troop
    {
        public APC(Player owner, GameState game)
        {
            name = "APC";
            description = "Strong and fast, however less effective in combat than the Jeep.";
            health = 18;
            armor = 2;
            armorType = "Heavy";
            visibility = 3;
            infantry = false;
            this.owner = owner;

            cost = 4;
            weapon = "Anti-Personnel Gun";
            movesPerTurn = 7;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.PIERCING, 2, 0, 2);
            attackTypeMechanical = new AttackType(AttackType.PIERCING, 2, 0, 2);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("apc");
        }
    }

    public class GaussTank : Troop
    {
        public GaussTank(Player owner, GameState game)
        {
            name = "Guass Tank";
            description = "An excellent killing machine.  Very offensive.";
            health = 12;
            armor = 2;
            armorType = "Heavy";
            visibility = 3;
            infantry = false;
            this.owner = owner;

            cost = 8;
            weapon = "Guass Cannon";
            movesPerTurn = 5;
            attacksPerTurn = 1;
            attackTypeInfantry = new AttackType(AttackType.EXPLOSIVE, 3, 0, 5);
            attackTypeMechanical = new AttackType(AttackType.EXPLOSIVE, 3, 0, 5);
            newTurn();
            this.unitTexture = game.push.Content.Load<Texture2D>("guass");
        }
    }
}
